package com.bjpowerndoe.ylb.web.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bjpowerndoe.ylb.domain.RechargeRecordPO;
import com.bjpowerndoe.ylb.mapper.RechargeRecordMapper;
import com.bjpowerndoe.ylb.web.service.inter.RechargeService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

@RequiredArgsConstructor
@Service
public class RechargeServiceImpl implements RechargeService {

    private final RechargeRecordMapper rechargeMapper;
    @Override
    public List<RechargeRecordPO> queryRechargeListByUid(Integer uid, Integer pageNo, Integer pageSize) {
        Page<RechargeRecordPO> pageResult = rechargeMapper.selectPage(
                new Page<RechargeRecordPO>(pageNo, pageSize),
                new QueryWrapper<RechargeRecordPO>()
                        .eq("uid", uid).orderByDesc("recharge_time"));

        return pageResult.getRecords();
    }
}
